<template>
  <div class="page-content-screen">
    <div class="screen">
<!--      <search-input title="关键词" :width="230" v-model="searchTxt"-->
<!--                    placeholder="请输入企业名称"-->
<!--                    @enter="handlerInput" @clear="handlerInput"/>-->
      <vc-filter :menus="screen"/>
    </div>
    <div class="total">共计 <span style="color: #FF5959;">{{ totalNum}}</span> 条</div>
  </div>
  <div class="page-content-table">
    <vc-table
      :loading="loading"
      :tableData="tableData"
      :columns="columns"
      :total="totalNum"
      :pageSize="PAGE_SIZE"
      :pageNum="queryData.pageNum"
      :defaultSort="{ field: 'noticeDate', order: 'desc' }"
      :maxHeight="500"
      @page-change="handleCurrentChange"
      @sort-change="sortChange"
    />
  </div>
</template>
<script lang="ts" setup>
import {getGreenBondCertification} from '../../../apis';
import {useTable} from './useTable';
import {useScreen} from './useScreen';
import {calculateTableMaxHeight} from "@/utils";
import searchInput from '@/components/page-search/index.vue';
import {usePage} from '@/use/usePage';

interface Props {
  companyId: string
}

const {
  companyId
} = defineProps<Props>();
const {PAGE_SIZE, screen, queryData} = useScreen(companyId);
let maxHeight = $ref(0)
queryData.evaluationAgencyCode = companyId
const {data, loading, run} = useRequest(getGreenBondCertification, {
  defaultParams: [{...queryData}],
  onSuccess: (data) => {
    tableData.value = data.values;
    totalNum.value = data.total;
    nextTick(() => {
      //计算最大高度
      maxHeight = calculateTableMaxHeight()
    })
  }
});
const {columns} = useTable();
const {
  tableData,
  totalNum,
  searchTxt,
  handlerInput,
  handleCurrentChange,
  sortChange
} = usePage(queryData, run);

</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
